package com.ss.android.article.base.ui;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.graphics.drawable.VectorDrawableCompat;

public final class j extends ak {
    public int a;
    public int b;
    private int c;
    private Context d;

    public j(Context arg2, int arg3) {
        super(arg2, arg3);
        this.a = 0;
        this.b = 0;
        this.c = arg3;
        this.d = arg2;
    }

    public final void draw(Canvas arg4, CharSequence arg5, int arg6, int arg7, float arg8, int arg9, int arg10, int arg11, Paint arg12) {
        Drawable v0 = this.getDrawable();
        if(v0 != null) {
            arg4.save();
            arg4.translate((((float)this.a)) + arg8, ((float)((arg11 - arg9 - v0.getBounds().bottom) / 2 + arg9)));
            v0.draw(arg4);
            arg4.restore();
        }
    }

    public final Drawable getDrawable() {
        Drawable v0;
        if(this.c == 0) {
            v0 = super.getDrawable();
            return v0;
        }

        try {
            v0 = VectorDrawableCompat.create(this.d.getResources(), this.c, this.d.getTheme());
            v0.setBounds(0, 0, v0.getIntrinsicWidth(), v0.getIntrinsicHeight());
        }
        catch(Resources.NotFoundException v0_1) {
            v0 = super.getDrawable();
        }

        return v0;
    }

    public final int getSize(Paint arg6, CharSequence arg7, int arg8, int arg9, Paint.FontMetricsInt arg10) {
        Drawable v1 = this.getDrawable();
        int v0 = 0;
        if(v1 != null) {
            Rect v0_1 = v1.getBounds();
            if(arg10 != null) {
                Paint.FontMetricsInt v1_1 = arg6.getFontMetricsInt();
                int v1_2 = v1_1.bottom - v1_1.top;
                int v2 = v0_1.bottom - v0_1.top;
                int v3 = v2 / 2 - v1_2 / 4;
                v1_2 = v1_2 / 4 + v2 / 2;
                arg10.ascent = -v1_2;
                arg10.top = -v1_2;
                arg10.bottom = v3;
                arg10.descent = v3;
            }

            v0 = v0_1.width() + this.a + this.b;
        }

        return v0;
    }
}

